<?php
/**
 * Created by PhpStorm.
 * User: Thans
 * Date: 2018/9/12
 * Time: 23:30
 */

namespace app\admin\controller;


use app\common\controller\Admin;
use app\user\facade\User;
use think\facade\Request;

class ProfileController extends Admin
{

    public function index()
    {
        $data = Request::only(['sex', 'birthday', 'user_nickname', 'user_url', 'avatar', 'signature']);
        $res = User::updateSelfInfo($data);
        $this->results($res);
    }

    public function changePwd()
    {
        $data['old_pass'] = Request::param('old_pass');
        $data['confirm_user_pass'] = Request::param('confirm_user_pass');
        $data['user_pass'] = Request::param('user_pass');
        $result = $this->validate($data, 'app\admin\validate\UserValidate.update_self_pass');
        if (true !== $result) {
            return $this->results([
                'code' => 4001,
                'msg' => $result,
                'data' => []
            ]);
        }
        $res = User::updateSelfPass($data);
        $this->results($res);
    }

}